package top.sjydzq.one.Mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import top.sjydzq.one.Entity.Comment;

import java.util.List;

@Mapper
@Repository
public interface CommentMapper {
    @Select("SELECT * FROM comment WHERE arti_id=#{artiId} ORDER BY id DESC")
    List<Comment> selectAllByArticleId(int artiId);

    @Insert("INSERT INTO comment(username, content, arti_id) VALUES(#{username}, #{content}, #{artiId})")
    boolean addComment(Comment comment);
}
